import 'package:flutter/material.dart';
import 'package:flutterlib/common/net/dao_result.dart';
import 'package:flutterlib/common/style/quhui_style.dart';
import 'package:flutterlib/common/utils/utils.dart';
import 'package:flutterlib/model/activity/activity_detail_bean.dart';
import 'package:flutterlib/pages/base/base_sliver_list.dart';
import 'package:flutterlib/widgets/back_button.dart';
import 'package:flutterlib/widgets/bussiness/user_info_widget.dart';
import 'package:flutterlib/widgets/pull/nested/simple_pull_load_manger.dart';

class ActivityJoinMemberPage extends BaseSliverList {
  final int type;
  final List<Join_members> joinMembers;

  ActivityJoinMemberPage({Key key, this.type, this.joinMembers})
      : super(key: key);

  @override
  ActivityJoinMemberPageState createState() => ActivityJoinMemberPageState();
}

///页面 KeepAlive ，同时支持 动画Ticker
class ActivityJoinMemberPageState extends BaseSliverListState<ActivityJoinMemberPage>
     {
  SimplePullLoadManger manger;

  ///滑动监听
  final ScrollController scrollController = new ScrollController();

  getDataLogic(int page) async {
    print(page);

    return new DataResult(widget.joinMembers, true);
  }

  Widget renderItem(index, memberItem) {
    //提交
    // var activity = pullLoadWidgetControl.dataList[index];
    return JoinMemberItem(member: memberItem);
  }

  @override
  List<Widget> renderHeader(BuildContext context, bool innerBoxIsScrolled) {
    return <Widget>[];
  }

  @override
  renderActions() {
    return <Widget>[];
  }

  @override
  Widget renderLeading() {
    return MyBackButton(
      color: Colors.black,
    );
  }

  @override
  Widget renderTitle() {
    return Text("已加入人员", style: QuhuiConstant.normalTextBold);
  }

  @override
  bool enablePullDown() {
    return false;
  }

  @override
  bool enablePullUp() {
    return false;
  }
}

class JoinMemberItem extends StatelessWidget {
  final Join_members member;

  const JoinMemberItem({Key key, this.member}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ClipRRect(
      borderRadius: const BorderRadius.all(Radius.circular(10.0)),
      child: Container(
        color: QuhuiColors.white,
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Expanded(
              child: Container(
                child: Padding(
                  padding: const EdgeInsets.only(
                      left: 16, top: 8, bottom: 0),
                  child: Row(
                    children: [
                      UserInfoWidget(
                        width: 33,
                        height: 33,
                        image: member.userLogo,
                        onPressed: () {
                          NavigatorUtils.goUserHome(
                              context, member.userId);
                        },
                      ),
                      Text(
                        member.userName,
                        style: QuhuiConstant.smallSubText,
                      ),
                    ],
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
